FluxBB et Gravatar

Posted by pulkomandy on Sun Jun 28 00:58:17 2009  •  Comments (1)  • 

gravatar.com est un site qui offre un service global de stockage d'avatars. On s'inscrit une fois, on uploade un avatar, et on peut l'utiliser pour tous les sites qui supportent le système. Je suis administrateur d'un forum fluxbb et j'ai décidé de mettre ça en place plutôt que de laisser les utilisateurs remplir mon serveur avec leurs avatars. Ça a été plutôt simple a faire:

gravatar.com is a website allowing his users to register, upload their favorite avatar once, and then use it everywhere. I've added support for it to a fluxbb forum. The hack was pretty simple:

(code original de fluxbb dans view_post.php) (original code in view_post.php)

  if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
  {
   if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
    $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' alt="" />';
   else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
    $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' alt="" />';
   else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
    $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' alt="" />';
  }
  else
   $user_avatar = '';

(a remplacer par) (replace with)

  $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5( strtolower($cur_post['email']) ).
//  "&default=".urlencode("http://une_belle_image").
  "&size=60";

  $user_avatar = '< img src="'.$grav_url.'">';

Le seul problème est que ça oblige tous vos utilisateurs a utilise gravatar pour leur avatar, il n'est plus possible de l'uploader chez vous ou de le faire venir d'un autre site. Mais vous saurez surement trouver une solution plus propre pour faire ça :)

The only drawback is that it enforces your users to upload their avatars to gravatar. They can't use another website or your own server. But i'm sure you can find a proper way to do it if you want :)

gravatar Comment

Posted by PulkoMandy on Sun Jun 28 11:51:38 2009

Gravatar est aussi utilisé dans ce formulaire de commentaires!

Leave a comment

Name: Mail: